package com.snatch.snatchnd.system;

import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.snatch.common.vo.NodeWeb;
import com.snatch.common.vo.WebConfig;
import com.snatch.work.vo.SystemConfig;


/**
 * 系统内存数据
 * 
 * @author Administrator
 * 
 */
public class SystemData {

	static public NodeWeb nodeWebs = new NodeWeb(); // 节点配置信息
	
	static public SystemConfig systemConfig = new SystemConfig();
	
	
	/**
	 * 系统维护等状态 key为网站名称
	 */
	static public ConcurrentMap<String, String> systemType = new ConcurrentHashMap<String, String>();
	
	
	public static WebConfig findWebConfig(String webCode){
		List<WebConfig> list = nodeWebs.getWebConfigs();
		for(WebConfig webConfig:list){
			if(webConfig.getWebCode().equals(webCode)){
				return webConfig;
			}
		}
		return null;
	}
	
	
	/*static public Boolean hasError = false; // 注册节点时,是否存在错误的标识

	static public ConcurrentMap<String, LoginThread> loginItemStatus = new ConcurrentHashMap<String, LoginThread>();// 每个登录线程的名字和线程ID

	static public ConcurrentMap<String, SnatchThread> snatchItemStatus = new ConcurrentHashMap<String, SnatchThread>();// 每个抓取线程的名字和线程ID

	static public ConcurrentMap<String, SnatchItemQueueBean> snatchItemSeqStackMap = new ConcurrentHashMap<String, SnatchItemQueueBean>();// 每个抓取线程版本号内存队列
	
	public static class SnatchItemQueueBean {
		public LinkedList<Map<String, Object>> snatchItemSeqStack;
		public Thread snatchItemSeqConsumer;
	}

	*//**
	 * 获得节点注册时,是否存在错误的标识
	 * 
	 * @return
	 *//*
	public static Boolean getHasError() {
		return hasError;
	}

	*//**
	 * 设置节点注册时,是否存在错误的标识
	 * 
	 * @param hasError
	 *//*
	public static void setHasError(Boolean _hasError) {
		hasError = _hasError;
	}

	*//**
	 * 获取相应抓取项的配置对象
	 * 
	 * @param thirdSystem
	 *            第三方系统(皇冠,利记,沙巴)
	 * @param snatchItem
	 *            抓取项{足球.单式(沙巴单式分单双与让球盘/大小球/标准盘), 足球.滚球}
	 * @return
	 *//*
	public static Config getConfigByCondition(String thirdSystem, String snatchItem) {
		if (null != thirdSystem && null != snatchItem) {
			if (null != nodeConfigs) {
				List<Config> configs = nodeConfigs.getConfigs();
				if (null != configs && configs.size() > 0) {
					for (Config config : configs) {
						if (config.getThirdSystem().equals(thirdSystem)) {
							if (config.getSnatchItem().equals(snatchItem)) {
								return config;
							}
						}
					}
				}
			}
		}
		return null;
	}

	*//**
	 * 获取相应抓取项的多帐户配置对象
	 * 
	 * @param thirdSystem
	 *            第三方系统(皇冠,利记,沙巴)
	 * @param snatchItem
	 *            抓取项{足球.单式(沙巴单式分单双与让球盘/大小球/标准盘), 足球.滚球}
	 * @return
	 *//*
	public static MoreAccountConfig getMoreAccountConfigByCondition(String thirdSystem, String snatchItem) {
		if (null != thirdSystem && null != snatchItem) {
			if (null != nodeConfigs) {
				List<MoreAccountConfig> configs = nodeConfigs.getConfigs();
				if (null != configs && configs.size() > 0) {
					for (MoreAccountConfig config : configs) {
						if (config.getThirdSystem().equals(thirdSystem)) {
							if (config.getSnatchItem().equals(snatchItem)) {
								return config;
							}
						}
					}
				}
			}
		}
		return null;
	}
	
	*//**
	 * 获取所有账号信息
	 * @return
	 * @author duanhx
	 *//*
	public static List<MoreAccountConfig> getAllAccounts() {

		return nodeConfigs.getConfigs();
	}*/
}
